// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

#ifndef HOST_PROCESSOR_OBSERVER_H_
#define HOST_PROCESSOR_OBSERVER_H_

#include "status/rot_status.h"


/**
 * Observer interface for handling host processor events.
 */
struct host_processor_observer {
	/**
	 * Notification that a host reset was completed.  If possible, this event is triggered before
	 * the host has been released to run and while the RoT still has access to host flash.
	 *
	 * Arguments passed with the notification will never be null.
	 *
	 * @param observer The observer instance being notified.
	 */
	void (*on_soft_reset) (struct host_processor_observer *observer);

	/**
	 * Notification that a host was configured to operate in bypass mode.
	 *
	 * Arguments passed with the notification will never be null.
	 *
	 * @param observer The observer instance being notified.
	 */
	void (*on_bypass_mode) (struct host_processor_observer *observer);

	/**
	 * Notification that host firmware was verified successfully against the active PFM and the host
	 * was configured to operate in active mode.
	 *
	 * Arguments passed with the notification will never be null.
	 *
	 * @param observer The observer instance being notified.
	 */
	void (*on_active_mode) (struct host_processor_observer *observer);

	/**
	 * Notification that host recovery has been initiated using a provisioned recovery image.
	 *
	 * Arguments passed with the notification will never be null.
	 *
	 * @param observer The observer instance being notified.
	 */
	void (*on_recovery) (struct host_processor_observer *observer);
};


#define	HOST_PROCESSOR_OBSERVER_ERROR(code)		ROT_ERROR (ROT_MODULE_HOST_PROCESSOR_OBSERVER, code)

/**
 * Error codes that can be generated by a host processor observer.
 */
enum {
	HOST_PROCESSOR_OBSERVER_INVALID_ARGUMENT = HOST_PROCESSOR_OBSERVER_ERROR (0x00),	/**< Input parameter is null or not valid. */
	HOST_PROCESSOR_OBSERVER_NO_MEMORY = HOST_PROCESSOR_OBSERVER_ERROR (0x01),			/**< Memory allocation failed. */
};


#endif /* HOST_PROCESSOR_OBSERVER_H_ */
